//package com.cssy.yd.logic.job;
//
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import org.quartz.Job;
//import org.quartz.JobExecutionContext;
//import org.quartz.JobExecutionException;
//
//import com.byd.acegiext.domain.User;
//import com.cssy.yd.basic.entity.BasicStorageinfoDO;
//import com.cssy.yd.basic.service.IBasicHarborService;
//import com.cssy.yd.basic.service.IBasicStorageService;
//import com.cssy.yd.logic.entity.LogicPoDO;
//import com.cssy.yd.logic.entity.LogicPoItemDO;
//import com.cssy.yd.logic.entity.LogicWhAffDO;
//import com.cssy.yd.logic.service.ILogicPoItemService;
//import com.cssy.yd.logic.service.ILogicPoService;
//import com.cssy.yd.logic.service.ILogicWhAffStockService;
//import com.plat.exception.SyBaseException;
//import com.plat.helper.SearchCondition;
//import com.plat.helper.SearchConditions;
//import com.plat.helper.SearchResult;
//import com.plat.util.DateUtils;
//import com.plat.util.SessionUtil;
//
//
//
//public class PoToWh {
//
//	@Resource(name = "basicwhService")
//	private IBasicStorageService basicwhService;
//	
//	@Resource(name = "logicPoService")
//	private ILogicPoService logicPoService;
//	
//	@Resource(name = "logicPoItemService")
//	private ILogicPoItemService logicPoItemService;
//	
//	@Resource(name = "logicWhAffStockService")
//	private ILogicWhAffStockService logicWhAffStockService;
//
//	public void execute() {
//		System.out.println(DateUtils.dateToString(new Date(),
//				"yyyy-MM-dd HH:mm:ss") + "执行采购订单自动调拨到虚礼港口开始.....");
//		User user=new User("System","system",false);
//		try {
//			SearchConditions scs = new SearchConditions();
//			scs.addCondition("billstatus", "1", SearchCondition.OP_EQUAL);
//			SearchResult result= logicPoService.findListByExample(scs);
//			List<LogicPoDO> po=result.getResults();
//			String date=DateUtils.dateToString(new Date(),"yyyy-MM-dd");
//			for(LogicPoDO pd : po){
//				String pdate=DateUtils.dateToString(pd.getDgrq(),"yyyy-MM-dd");
//				if(date.equals(pdate)){
//					//查询港口下面的虚礼仓库
//					SearchConditions sc = new SearchConditions();
//					sc.addCondition("nature", "1", SearchCondition.OP_EQUAL);
//					sc.addCondition("harborname", pd.getWhname(), SearchCondition.OP_EQUAL);
////					sc.addCondition("harborid", pd.getWhcode(), SearchCondition.OP_EQUAL);
//					SearchResult sr= basicwhService.findListByExample(sc);
//					List<BasicStorageinfoDO> storage=sr.getResults();
//					//查询该订单的物料
//					SearchConditions ss = new SearchConditions();
//					ss.setRemovedProperty(null);//判断是否有删除标识
//					ss.addCondition("poid", pd.getId(), SearchCondition.OP_EQUAL);
//					List<LogicPoItemDO> itemlistDos=logicPoItemService.findListByExample(ss).getResults();
//					if(itemlistDos.size()>0){
//						for(int i=0;i<itemlistDos.size();i++){
//							LogicWhAffDO lwhaff=new LogicWhAffDO();
//							lwhaff.setBillCode(pd.getPocode());
//							lwhaff.setBillType("XL");
//							lwhaff.setWhCode(storage.get(0).getCode());
//							lwhaff.setBrand(itemlistDos.get(i).getBrand());
//							lwhaff.setHubName(storage.get(0).getName());
//							lwhaff.setCreategscode(pd.getCreategscode());
//							lwhaff.setCreategsname(pd.getCreategsname());
//							lwhaff.setUnit(itemlistDos.get(i).getUnit());
//							lwhaff.setPrice(itemlistDos.get(i).getPrice());
//							lwhaff.setCode(itemlistDos.get(i).getCode());
//							lwhaff.setName(itemlistDos.get(i).getName());
//							lwhaff.setSpec(itemlistDos.get(i).getSpec());
//							lwhaff.setStockPrice(itemlistDos.get(i).getPrice());
//							lwhaff.setStatus("1");
//							lwhaff.setQuantity(itemlistDos.get(i).getQuantity());
//							if (itemlistDos.get(i).getQuantity() != null && !"".equals(itemlistDos.get(i).getQuantity()) && itemlistDos.get(i).getQuantity() > 0 )
//								logicWhAffStockService.updateWhAffstockQuantity(lwhaff, user,true);
//						}
//					}
//					pd.setBillstatus(Short.parseShort("4"));
//					logicPoService.update(pd, user);
//				}
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//			System.out.println(DateUtils.dateToString(new Date(),
//					"yyyy-MM-dd HH:mm:ss") + "执行采购订单自动调拨到虚礼港口是发生错误.....");
//		}
//		System.out.println(DateUtils.dateToString(new Date(),
//				"yyyy-MM-dd HH:mm:ss") + "执行采购订单自动调拨到虚礼港口结束.....");
//	}
//}
